﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Configuration;

namespace BLL.SUBSYSTEM
{
   /// <summary>
	/// 业务逻辑类SUBSYS_INFO 的摘要说明。
	/// </summary>
	public class SUBSYS_INFO
	{
		private readonly OracleDAL.SUBSYSTEM.SUBSYS_INFO dal=new OracleDAL.SUBSYSTEM.SUBSYS_INFO();
        private static string imagePath = ConfigurationManager.AppSettings["ImagePath"].ToString();

        /// <summary>
        /// 
        /// </summary>
		public SUBSYS_INFO()
		{}
		#region  成员方法
		/// <summary>
		/// 是否存在该记录
		/// </summary>
		public bool Exists(string SUBSYSTEMID)
		{
			return dal.Exists(SUBSYSTEMID);
		}

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public void Add(Model.SUBSYSTEM.SUBSYS_INFO model)
		{
			dal.Add(model);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public void Update(Model.SUBSYSTEM.SUBSYS_INFO model)
		{
			dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public void Delete(string SUBSYSTEMID)
		{
			
			dal.Delete(SUBSYSTEMID);
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public Model.SUBSYSTEM.SUBSYS_INFO GetModel(string SUBSYSTEMID)
		{
			
			return dal.GetModel(SUBSYSTEMID);
		}

        ///// <summary>
        ///// 得到一个对象实体，从缓存中。
        ///// </summary>
        //public Model.SUBSYSTEM.SUBSYS_INFO GetModelByCache(string SUBSYSTEMID)
        //{
			
        //    string CacheKey = "SUBSYS_INFOModel-" + SUBSYSTEMID;
        //    object objModel = LTP.Common.DataCache.GetCache(CacheKey);
        //    if (objModel == null)
        //    {
        //        try
        //        {
        //            objModel = dal.GetModel(SUBSYSTEMID);
        //            if (objModel != null)
        //            {
        //                int ModelCache = LTP.Common.ConfigHelper.GetConfigInt("ModelCache");
        //                LTP.Common.DataCache.SetCache(CacheKey, objModel, DateTime.Now.AddMinutes(ModelCache), TimeSpan.Zero);
        //            }
        //        }
        //        catch{}
        //    }
        //    return (Model.SUBSYSTEM.SUBSYS_INFO)objModel;
        //}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<Model.SUBSYSTEM.SUBSYS_INFO> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<Model.SUBSYSTEM.SUBSYS_INFO> DataTableToList(DataTable dt)
		{
			List<Model.SUBSYSTEM.SUBSYS_INFO> modelList = new List<Model.SUBSYSTEM.SUBSYS_INFO>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				Model.SUBSYSTEM.SUBSYS_INFO model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = new Model.SUBSYSTEM.SUBSYS_INFO();
					model.SUBSYSTEMID=dt.Rows[n]["SUBSYSTEMID"].ToString();
					model.SUBSYSTEMNAME=dt.Rows[n]["SUBSYSTEMNAME"].ToString();
					model.SUBSYSTEMLOGONMETHOD=dt.Rows[n]["SUBSYSTEMLOGONMETHOD"].ToString();
					model.SUBSYSTEMLOGONURL=dt.Rows[n]["SUBSYSTEMLOGONURL"].ToString();
					model.SUBSYSTEMCREATEUSERISN=dt.Rows[n]["SUBSYSTEMCREATEUSERISN"].ToString();
					if(dt.Rows[n]["SUBSYSTEMCREATETIME"].ToString()!="")
					{
						model.SUBSYSTEMCREATETIME=DateTime.Parse(dt.Rows[n]["SUBSYSTEMCREATETIME"].ToString());
					}
					if(dt.Rows[n]["SUBSYSTEMCHANGETIME"].ToString()!="")
					{
						model.SUBSYSTEMCHANGETIME=DateTime.Parse(dt.Rows[n]["SUBSYSTEMCHANGETIME"].ToString());
					}
					model.SUBSYSTEMCHANGEUSERISN=dt.Rows[n]["SUBSYSTEMCHANGEUSERISN"].ToString();
					model.SUBSYSTEMSTATE=dt.Rows[n]["SUBSYSTEMSTATE"].ToString();
					model.SUBSYSTEMRUNNINGSTATE=dt.Rows[n]["SUBSYSTEMRUNNINGSTATE"].ToString();
					model.SUBSYSTEMTYPE=dt.Rows[n]["SUBSYSTEMTYPE"].ToString();
					model.SUBSYSTEMUSERMANAGETYPE=dt.Rows[n]["SUBSYSTEMUSERMANAGETYPE"].ToString();
					model.SUBSYSTEMREMARK=dt.Rows[n]["SUBSYSTEMREMARK"].ToString();
                    model.SUBSYSIMAGE = imagePath + dt.Rows[n]["SUBSYSIMAGE"].ToString();//修改子系统的图标的位置
                    model.ISDISPLAY = dt.Rows[n]["ISDISPLAY"].ToString();
                    model.DIRECTION = dt.Rows[n]["DIRECTION"].ToString();
					modelList.Add(model);
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		//public DataSet GetList(int PageSize,int PageIndex,string strWhere)
		//{
			//return dal.GetList(PageSize,PageIndex,strWhere);
		//}

		#endregion  成员方法
	}
}
